﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:ddw1="http://microsoft.com/webservices/OfficeServer/QueryService"
                version="1.0"
                exclude-result-prefixes="xsl msxsl ddwrt"
                xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
                xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
                xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:SharePoint="Microsoft.SharePoint.WebControls"
                xmlns:ddwrt2="urn:frontpage:internal">
  <xsl:output method="html"
              indent="no" />
  <xsl:decimal-format NaN="" />
  <xsl:param name="FileName" />
  <xsl:param name="WebPartId" />
  <xsl:param name="dvt_apos">'</xsl:param>
  <xsl:variable name="dvt_1_automode">0</xsl:variable>
  <xsl:template match="/"
                xmlns:ddw1="http://microsoft.com/webservices/OfficeServer/QueryService"
                xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
                xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
                xmlns:SharePoint="Microsoft.SharePoint.WebControls">
    <xsl:call-template name="dvt_1" />
  </xsl:template>
  <xsl:template name="dvt_1">
    <xsl:variable name="dvt_StyleName">2ColFrm</xsl:variable>
    <xsl:variable name="Rows"
                  select="/ddw1:QueryExResponse/Results/RelevantResults" />
    <table border="0"
           cellspacing="0"
           width="100%">
      <tr>
        <xsl:call-template name="dvt_1.body">
          <xsl:with-param name="Rows"
                          select="$Rows" />
        </xsl:call-template>
      </tr>
    </table>
  </xsl:template>
  <xsl:template name="dvt_1.body">
    <xsl:param name="Rows" />
    <xsl:for-each select="$Rows">
      <xsl:call-template name="dvt_1.rowview" />
    </xsl:for-each>
  </xsl:template>
  <xsl:template name="dvt_1.rowview">
    <xsl:variable name="id"
                  select="WORKID" />
    <xsl:variable name="url"
                  select="PATH" />
    <xsl:variable name="email"
                  select="WORKEMAIL" />
    <xsl:variable name="prefix">IMNRC('</xsl:variable>
    <xsl:variable name="suffix">')</xsl:variable>

    <xsl:variable name="preferredname">
      <xsl:choose>
        <xsl:when test="string-length(substring-after(TITLE, ';#')) &gt; 0">

          <xsl:value-of select="substring-after(TITLE, ';#')" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="TITLE" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <xsl:variable name="pictureUrl">
      <xsl:choose>
        <xsl:when test="string-length(PICTUREURL) &gt; 0">
          <xsl:value-of select="PICTUREURL" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>_layouts/images/no_pic.gif</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

    <td valign="top"
        width="50%">
      <table border="0"
             cellspacing="0"
             style="margin-bottom:8px">
        <tr>
          <td class="ms-vb">
            <img id="{concat($WebPartId,'_PictureUrlImage_',$id)}"
                 onload="imgResizeMax('{concat($WebPartId,'_PictureUrlImage_',$id)}', 100);imgResizeTbl('{concat($WebPartId,'_PictureUrlImage_',$id)}');"
                 src="{$pictureUrl}"
                 alt="User Photo"
                 style="border-width:0px;" />
          </td>
          <td valign="top">
            <table border="0"
                   cellspacing="0"
                   width="100%"
                   align="left">
              <tr>
                <td width="75%"
                    class="ms-vb">
                  <span>
                    <img border="0"
                         height="12"
                         width="12"
                         src="/_layouts/images/imnhdr.gif"
                         onload="{concat($prefix, $email, $suffix)}"
                         ShowOfflinePawn="1"
                         id="{concat($WebPartId,'_HSRP_',$id)}" />
                    <xsl:text disable-output-escaping="yes">
&amp;nbsp;
</xsl:text>
                    <a href="{$url}"
                       id="{concat($WebPartId,'_HSR_',$id)}">
                      <xsl:value-of select="$preferredname" />
                    </a>
                  </span>
                </td>
              </tr>
              <tr>
                <td width="75%"
                    class="ms-vb">
                  <xsl:value-of select="JOBTITLE" />
                </td>
              </tr> 
              <tr>
                <td width="75%"
                    class="ms-vb">
                  <xsl:value-of select="$email" />
                </td>
              </tr>
              <tr>
                <td width="75%"
                    class="ms-vb">
                  <xsl:value-of select="WORKPHONE" />
                </td>
              </tr>
              <xsl:if test="$dvt_1_automode = '1'"
                      ddwrt:cf_ignore="1">
                <tr>
                  <td colspan="99"
                      class="ms-vb">
                    <span ddwrt:amkeyfield=""
                          ddwrt:amkeyvalue="string($XPath)"
                          ddwrt:ammode="view" />
                  </td>
                </tr>
              </xsl:if>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <xsl:if test="position() mod 2 = 0"
            ddwrt:cf_ignore="1">
      <xsl:text disable-output-escaping="yes">
&lt;/tr&gt;
</xsl:text>
      <xsl:if test="position() != last()"
              ddwrt:cf_ignore="1">
        <xsl:text disable-output-escaping="yes">
&lt;tr&gt;
</xsl:text>
      </xsl:if>
    </xsl:if>
    <xsl:if test="position() = last()"
            ddwrt:cf_ignore="1">
      <xsl:if test="position() mod 2 != 0"
              ddwrt:cf_ignore="1">
        <td>
          <xsl:text disable-output-escaping="yes"
                    ddwrt:nbsp-preserve="yes">
&amp;nbsp;
</xsl:text>
        </td>
      </xsl:if>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>
